package com.cocolover2.andbase.mvpbase;

import android.os.Bundle;

import com.cocolover2.andbase.AndBaseFragment;

/**
 * <p>
 * 功能同{@link MVPBaseActivity}
 * </p>
 *
 * @param <V>
 * @param <P>
 * @author liubo
 */
public abstract class MVPBaseFragment<V extends ImvpBaseView, P extends AppBasePresenter<V>> extends AndBaseFragment {

    protected P mPresenter;


    @SuppressWarnings("unchecked")
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mPresenter = createPresenter();
        mPresenter.attachView((V) this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPresenter != null)
            mPresenter.detachView();
    }

    protected abstract P createPresenter();
}
